package cn.gray.gae.job.daily.server;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

/**
 * @author teawooo <long1795@gmail.com>
 */
@Controller
public class ScopeController {

	/*
	 * (non-Javadoc)
	 * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@RequestMapping(value = "/scope.htm", method = { RequestMethod.GET })
	public String handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {

		UserService userService = UserServiceFactory.getUserService();
		if (userService == null) {
			return "userService is null";
		}
		User user = userService.getCurrentUser();
		if (user == null) {
			return "user is null";
		}
		return "succ--" + user.getEmail();
	}

}
